<!DOCTYPE HTML>
<!--
	Dimension by HTML5 UP
	html5up.net | @ajlkn
	Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
 <head>
  <title>
   Dimension by HTML5 UP
  </title>
  <!-- <meta charset="utf-8" /> -->
  <!-- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> -->
  <meta charset="utf-8"/>
  <meta content="width=device-width,initial-scale=1.0" name="viewport"/>
  <link href="../../assets/css/article.css" rel="stylesheet"/>
  <link href="https://cdn.bootcss.com/highlight.js/9.15.8/styles/github.min.css" rel="stylesheet"/>
  <noscript>
   <link href="../../assets/css/noscript.css" rel="stylesheet"/>
  </noscript>
 </head>
 <body>
  <div id="app">
  </div>
  <!-- built files will be auto injected -->
 </body>
 <body class="is-preload">
  <!-- Wrapper -->
  <div id="wrapper">
   <!-- Main -->
   <div id="main">
    <article id="article">
     <h1 id="sfml-vs2015">
      SFML 与 VS2015 的安装配置
     </h1>
     <hr/>
     <h2 id="_1">
      一、下载
     </h2>
     <p>
      在官网下载 IDE 对应版本的 SFML，本安装教程使用的 IDE 是 VS2015，下载地址是：
      <a href="https://www.sfml-dev.org/tutorials/2.4/start-vc.php">
       https://www.sfml-dev.org/tutorials/2.4/start-vc.php
      </a>
     </p>
     <h2 id="_2">
      二、解压安装
     </h2>
     <p>
      把下载下来的相应安装包解压至任意文件下（看你心情，想放哪就放哪，但需要记住你放的位置），本教程将其解压至 C:\Program Files\SFML，然后呢？嗯，这样就完成了，是不是很简单！因为下载的这个是已经被别人编译好的版本了，我们不用自己再重新编译了，直接用就行的。
     </p>
     <h2 id="_3">
      三、环境变量的配置
     </h2>
     <p>
      将 C:\Program Files\SFML\SFML-2.4.2\bin 添加到系统的环境变量中，这个怎么添加网上有很多的教程，照着弄就行了。记得添加完成以后要重启或者注销计算机才行，不然也用不了
     </p>
     <h2 id="vs2015">
      四、VS2015 的相应配置
     </h2>
     <ul>
      <li>
       1.新建项目以后，选中项目右击选中属性
      </li>
      <li>
       2.在左上方的平台选择：X64
      </li>
      <li>
       3.左边的配置属性选择：VC++ 目录，在右边方框可以看到，可执行目录、饱含目录等等
      </li>
      <li>
       4.可执行目录中添加 C:\Program Files\SFML\SFML-2.4.2\bin（添加的路径已本教程 SFML 的解压路径相应来写的，看官自己的路径对照着来就行了）
      </li>
      <li>
       5.包含目录添加：C:\Program Files\SFML\SFML-2.4.2\include
      </li>
      <li>
       6.库目录添加：C:\Program Files\SFML\SFML-2.4.2\lib
      </li>
      <li>
       7.选择连接器--输入--附加依赖项，添加：
       <ul>
        <li>
         sfml-graphics-d.lib
        </li>
        <li>
         sfml-window-d.lib
        </li>
        <li>
         sfml-audio-d.lib
        </li>
        <li>
         sfml-network-d.lib
        </li>
        <li>
         sfml-system-d.lib
        </li>
       </ul>
      </li>
     </ul>
     <h2 id="_4">
      五、测试是否配置成功
     </h2>
     <p>
      上面基本配置完成了，接下来用一个测试程序来运行一下成功没有，把下面的代码复制粘贴到新建的 main.cpp 文件中，直接按 Ctrl+F5 运行，如果看到一个绿色的圆就说明配置完成了
     </p>
     <div class="codehilite">
      <pre><span></span><code><span class="cp">#include</span> <span class="cpf">&lt;SFML/Graphics.hpp&gt;</span><span class="cp"></span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
<span class="p">{</span>
    <span class="n">sf</span><span class="o">::</span><span class="n">RenderWindow</span> <span class="n">window</span><span class="p">(</span><span class="n">sf</span><span class="o">::</span><span class="n">VideoMode</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">),</span> <span class="s">"SFML works!"</span><span class="p">);</span>
    <span class="n">sf</span><span class="o">::</span><span class="n">CircleShape</span> <span class="n">shape</span><span class="p">(</span><span class="mf">100.f</span><span class="p">);</span>
    <span class="n">shape</span><span class="p">.</span><span class="n">setFillColor</span><span class="p">(</span><span class="n">sf</span><span class="o">::</span><span class="n">Color</span><span class="o">::</span><span class="n">Green</span><span class="p">);</span>

    <span class="k">while</span> <span class="p">(</span><span class="n">window</span><span class="p">.</span><span class="n">isOpen</span><span class="p">())</span>
    <span class="p">{</span>
        <span class="n">sf</span><span class="o">::</span><span class="n">Event</span> <span class="n">event</span><span class="p">;</span>
        <span class="k">while</span> <span class="p">(</span><span class="n">window</span><span class="p">.</span><span class="n">pollEvent</span><span class="p">(</span><span class="n">event</span><span class="p">))</span>
        <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">event</span><span class="p">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">sf</span><span class="o">::</span><span class="n">Event</span><span class="o">::</span><span class="n">Closed</span><span class="p">)</span>
                <span class="n">window</span><span class="p">.</span><span class="n">close</span><span class="p">();</span>
        <span class="p">}</span>

        <span class="n">window</span><span class="p">.</span><span class="n">clear</span><span class="p">();</span>
        <span class="n">window</span><span class="p">.</span><span class="n">draw</span><span class="p">(</span><span class="n">shape</span><span class="p">);</span>
        <span class="n">window</span><span class="p">.</span><span class="n">display</span><span class="p">();</span>
    <span class="p">}</span>

    <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
     </div>
    </article>
   </div>
   <!-- Footer -->
   <footer id="footer">
    <p class="copyright">
     © Untitled. Design:
     <a href="https://html5up.net">
      HTML5 UP
     </a>
     .
    </p>
   </footer>
  </div>
  <!-- BG -->
  <div id="bg">
  </div>
  <!-- Scripts -->
  <script src="../assets/js/jquery.min.js">
  </script>
  <script src="../assets/js/browser.min.js">
  </script>
  <script src="../assets/js/breakpoints.min.js">
  </script>
  <script src="../assets/js/util.js">
  </script>
  <script src="../assets/js/main.js">
  </script>
 </body>
</html>
